/**
 * 
 */
package com.topline.xiaocaifeng.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.topline.xiaocaifeng.service.WelcomeService;

/**
 * @author xuefei
 *
 */
@RestController
public class WelcomeController {

	@Autowired
	private WelcomeService welcomeService; 
	
	@Autowired
	ApplicationContext applicationContext;
	
	@Value("${server.port}")
	private String port;
	
	@Autowired
    ApplicationArguments arguments;
	
	@GetMapping("/getArgs")
	public String getParam(){
	    
	    boolean hasDebug = arguments.containsOption("debug");
	    List<String> toplines = arguments.getNonOptionArgs();
	    return "是否包含debug----"+hasDebug+"-----"+toplines.get(0);
	}
	
	@GetMapping("/getServerPort")
	public String getServerPort(){
	    return "当前服务的端口为："+port;
	}
	
	@RequestMapping("/index")
	public String index(){
	    System.out.println("the server port is:"+port);
		String[] beanNames = applicationContext.getBeanDefinitionNames();
		for(int i = 0;i<beanNames.length;i++){
			System.out.println(beanNames[i]);
		}
		
		return "当前时间为："+welcomeService.getCurrentTime();
	}
	
	
	   @RequestMapping("/goIndex")
	    public String goIndex(){
	       System.out.println("22tt2");
	        return "index";
	    }
	
	
	
	
}
